<%--
@Created by IntelliJ IDEA
@Project_Name ieco_server
@Package 
@Author ZhongYao_H
@Date 2019/5/14:10:02
@Year 2019 Month 05 Day 14
@Date_zh  2019年 五月 星期二
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico"> <link href="${pageContext.request.contextPath}/assets/hplus/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <%@include file="/WEB-INF/common/hplus-css.jsp"%>
    <%@include file="/WEB-INF/common/hplus-js.jsp" %>
    <style>

        html,body{
            height: 100%;
            width: 100%;
        }

    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content">

    <form  class="form-horizontal m-t" action="${pageContext.request.contextPath}/autorely/add" id="form" method="post">


        <div class="form-group">
            <label class="col-sm-3 control-label"><span>*</span>第一类型：</label>
            <div class="col-sm-7">
                <select class="form-control" onchange="select(this.value)" id="1" name="typeA">
                    <option value="1" >可回收</option>
                    <option value="2">不可回收</option>
                    <option value="0">其他</option>
                </select>
            </div>
        </div>
        <div class="form-group" id="s1">
            <label class="col-sm-3 control-label"><span id="required">*</span>第二类型：</label>
            <div class="col-sm-7">
                <select class="form-control" name="typeB" id="typeB1">
                    <option value="0">PET瓶</option>
                    <option value="1">PE瓶</option>
                    <option value="2">泡沫</option>
                    <option value="3">硬质塑料</option>
                    <option value="4">塑料袋膜</option>
                    <option value="5">织物</option>
                    <option value="6">玻璃</option>
                    <option value="7">复合</option>
                    <option value="8">电子电器</option>
                    <option value="9">书报</option>
                    <option value="10">综合纸</option>
                    <option value="11">金属</option>
                    <option value="12">铝拉罐</option>
                    <option value="13">黄纸板</option>
                </select>
            </div>
        </div>
        <div class="form-group" id="s3">
            <label class="col-sm-3 control-label">回收价格：</label>
            <div class="col-sm-7">
                <input type="text"  name="price" id="price" class="form-control"
                       placeholder="价格" required aria-required="true">
            </div>

        </div>

        <div class="form-group" id="s4">
            <label class="col-sm-3 control-label">计重单位：</label>
            <div class="col-sm-7">
                <select class="form-control" name="unit">
                    <option value="kg" >kg</option>
                    <option value="个" >个</option>
                </select>
            </div>

        </div>


        <div class="form-group" id="s2" style="display: none">
            <label class="col-sm-3 control-label"><span id="typeB">*</span>第二类型：</label>
            <div class="col-sm-7">
                <select class="form-control"  id="typeB2" >
                    <option value="-1">干垃圾</option>
                    <option value="-3">湿垃圾</option>W
                    <option value="-4">有害垃圾</option>
                </select>
            </div>
        </div>
        <div class="form-group" >
            <label class="col-sm-3 control-label"><span >*</span>是否第二类型：</label>
            <div class="col-sm-7">
                <select class="form-control" id="type" name="typeC">
                    <option value="-1">否</option>
                    <option value="-2">是</option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">关键字：</label>
            <div class="col-sm-7">
                <input type="text"  name="keyword" id="name" class="form-control"
                       placeholder="" required aria-required="true">
            </div>

        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">回复内容：</label>
            <div class="col-sm-7">
                <textarea type="text"  name="body"  id="lat" style="width: 100%;height: 250px" class="form-control" maxlength="2000"
                          placeholder=""></textarea>
            </div>

        </div>

    </form>
    <div class="form-group">&nbsp;
        <div class="col-sm-4 col-sm-offset-3" style="text-align: center;">
        </div>
    </div>
    <div class="form-group">&nbsp;
        <div class="col-sm-4 col-sm-offset-3" style="text-align: center;">
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-4 col-sm-offset-3" style="text-align: center;">
            <button class="btn btn-primary" id="add-btn" onclick="submit()" type="button">提交</button>
        </div>
    </div>

</div>




 <div id="hiden" style="display: none">
 <form id="fileform" action="${pageContext.request.contextPath}/file/uploadimage" enctype="multipart/form-data">
     <input name="file" id="file" accept="image/jpeg,image/jpg,image/png,image/gif" onchange="imgUpload(this)" type="file">
 </form>

 </div>

<!-- 全局js -->
<%--<script src="${pageContext.request.contextPath}/assets/hplus/js/jquery.min.js?v=2.1.4"></script>--%>
<script src="${pageContext.request.contextPath}/assets/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/hplus/js/bootstrap.min.js?v=3.3.6"></script>
<!-- 自定义js -->
<script src="${pageContext.request.contextPath}/assets/hplus/js/content.js?v=1.0.0"></script>
<!-- SUMMERNOTE -->
<script type="text/javascript">

    $(document).ready(function () {

    });


     function submit() {

         if ($("#lat").val()=='' || $("#name").val()=='' ){
             layer.msg('填写信息不完整',{icon:5})
             return
         }
             $("#form").ajaxSubmit({
                 dataType:'json',
                 type:"POST",
                 success:function (json) {
                     var code = json.code;
                     if (code==0){
                         layer.msg(json.msg,{icon:1})
                         setTimeout(function () {
                             parent.window.location.reload();
                         },1000)

                     }else {
                         layer.msg(json.msg,{icon:5})
                     }
                 }
             });

    }

    function hiden(type) {
        if (type==1){
            $("#s1").hide();
            $("#s3").hide();
            $("#s4").hide();
            $("#s2").show();
            $("#typeC").attr("name","typeC");
            $("#typeB2").attr("name","typeB");
            $("#typeB1").removeAttr("name");
        } else if (type==2) {
            $("#s1").show();
            $("#s3").show();
            $("#s4").show();
            $("#s2").hide();
            $("#typeC").attr("name","typeC");
            $("#typeB1").attr("name","typeB");
            $("#typeB2").removeAttr("name");
        }else if (type==3){
            $("#s1").hide();
            $("#s3").hide();
            $("#s4").hide();
            $("#s2").hide();

            $("#typeB1").removeAttr("name");
            $("#typeB2").removeAttr("name");
            $("#typeC").removeAttr("name");

        }

    }

    function select(val) {
        if (val==1){
            hiden(2);
        } else if (val==2){
            hiden(1)
        } else if (val==0){
            hiden(3)
        }


    }


</script>
</body>
</html>
